//
//  HttpRequest.h
//  网络请求1116Demo
//
//  Created by 铅笔 on 15/11/16.
//  Copyright © 2015年 铅笔. All rights reserved.
//
//网络请求
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
//请求方法define
typedef enum {
    GET,
    POST,
    PUT,
    DELETE,
    HEAD
} HTTPMethod;

typedef void (^transferValue) (id obj,NSError* error);

//请求成功回调block
typedef void (^requestSuccessBlock)(NSDictionary *dic);

//请求失败回调block
typedef void (^requestFailureBlock)(NSError *error);

@interface HttpRequest : NSObject

@property (nonatomic,strong) AFHTTPRequestOperationManager *manager;

+(HttpRequest *) shardWebUtil;

/**检测网路状态**/
+ (void)netWorkStatus;

/**
 *JSON方式获取数据 GET
 *urlStr:获取数据的url地址
 *
 */
-(void)getNetworkRequestURLString:(NSString *) urlString  andParas:(id) params andTransferGottenData:(transferValue) transfer;

/**
 *JSON方式获取数据 POST
 *urlStr:获取数据的url地址
 *
 */
-(void)postNetworkRequestURLString:(NSString *) urlString  andParas:(id) params andTransferGottenData:(transferValue) transfer;

/**
 *JSON方式获取数据 GET
 *url_path:获取数据的url地址
 *有返回值 类型
 */
- (AFHTTPRequestOperation*)getNetworkRequestURLString:(NSString *)url_path parameters:(id)parameters success:(void (^)(id obj))success fail:(void (^)(NSError *error))fail;

/**
 *JSON方式获取数据 POST
 *url_path:获取数据的url地址
 *有返回值 类型
 */
- (AFHTTPRequestOperation*)postNetworkRequestURLString:(NSString *)url_path parameters:(id)parameters success:(void (^)(id obj))success fail:(void (^)(NSError *error))fail;

- (void)requestWithMethod:(HTTPMethod)method
                 WithPath:(NSString *)path
               WithParams:(NSDictionary*)params
         WithSuccessBlock:(requestSuccessBlock)success
          WithFailurBlock:(requestFailureBlock)failure;

- (AFHTTPRequestOperation *)networkrequestWithMethod:(HTTPMethod)method
    WithPath:(NSString *)path
    WithParams:(NSDictionary*)params
    WithSuccessBlock:(requestSuccessBlock)success
    WithFailurBlock:(requestFailureBlock)failure;

@end
